PSQL Commands

Connect

If using Command line

 C:\"program files"\postgresql\18\bin\pg_dump -U postgres -d "Movies" -F c -f C:/Postgresqloutput/movies.backup

Change Directory to this

C:\"program files"\postgresql\18\bin


 psql.exe -U postgres -d dvdrental
 psql.exe -U postgres -d dvdrental -h 192.168.2.25

postgres=# \c Movies

Find Schema
SHOW search_path;

Change Schema
Movies=# SET search_path TO movies;

List databases
\l

List tables
\dt

Get Table design

\d language

Run a query

Movies=# select * from language;


send output to a file

--Windows
copy (SELECT * FROM Country) TO 'C:/Postgresqloutput/results.txt' CSV HEADER;

--Linux

COPY (SELECT * FROM country) TO '/var/lib/postgresql/results.txt' CSV HEADER;







